#ifndef STATE_H
#define STATE_H

#include <QList>
#include <math.h>

template<int n>
struct State
{
    QList<double> params;
    QList<double> cons;
    double V;

    State();
    State(QList<double> list ):params(list), V(0){}

    inline double distanceTo(QList<double> list)
    {
        double result = 0;
        double temp;

        for(int i=0; i<n; i++)
        {
            temp = list[i] - params[i];
            result += temp*temp;
        }
        return(sqrt(result));
    }    
};

template<int n>
inline bool operator<(State<n> left, State<n> right)
{
    for(int i=0; i<n; i++)
    {
        if(left.params[i] < right.params[i])
        {
            return(true);
        }
        if(left.params[i] > right.params[i])
        {
            return(false);
        }
    }
    return(false);
}

#endif // STATE_H
